Executes the given action until getting of successful result specified number of times.
A zero-based index of current iteration is passed as a parameter to action.